<?php

//achtung noch von extern ge&ouml;ffnet
$path = $_GET['i'];

//change this for other image sizes
$max_width = 16;
$max_height = 16;


//get information from original image
$path = urldecode($path);
$info = getimagesize($path);
$width = $info[0]; //image width
$height = $info[1]; //image height
$type = $info[2]; //image type

//choose which imagetype have to create
if ($type=="1") $image = imagecreatefromgif($path);
if ($type=="2") $image = imagecreatefromjpeg($path);
if ($type=="3") $image = imagecreatefrompng($path);

//get the formate
if ($height>=$width) {
    $new_height = $max_height;
    $new_width = $new_height / $height * $width;
    if ($new_width<1) $new_width = 1;
}
else {
    $new_width = $max_width;
    $new_height = $new_width / $width * $height;
    if ($new_height<1) $new_height = 1;
}

//create Image
$new_image = imagecreatetruecolor($new_width,$new_height);

//copy and resize orginal image to preview image
imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

//change the number to change the quality of thumbtail (lower quality = smaller filesize = faster)
//at smaller sizes the quality can be 100...
imagejpeg($new_image, "", 100);
?>
